package eight.test_8_3;

import java.util.Scanner;

public class TestMain2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int k = scanner.nextInt();
        int[] wi = new int[n + 1];
        int[] vali = new int[n + 1];
        boolean[][] exclude = new boolean[n + 1][n + 1];
        for (int i = 1; i <= n; i++) {
            wi[i] = scanner.nextInt();
            vali[i] = scanner.nextInt();
        }
        for (int i = 0; i < k; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            exclude[a][b] = true;
            exclude[b][a] = true;
        }
        int[][] dp = new int[n + 1][m + 1];
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j <= m; j++) {
                dp[i][j] = dp[i - 1][j];
                if(j >= wi[i]) {
                    int maxVal = dp[i - 1][j - wi[i]] + vali[i];
                    boolean canTake = true;
                    for (int x = 1; x < i; x++) {
                        if(exclude[i][x] && dp[i - 1][j - wi[i]] == dp[x][j - wi[i]] + vali[x]) {
                            canTake = false;
                            break;
                        }
                    }
                    if(canTake) {
                        dp[i][j] = Math.max(dp[i][j],maxVal);
                    }
                }
            }
        }
        System.out.println(dp[n][m]);
    }
}
